import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";

/**
 * 工作区 Header
 *
 * @date: 2018-6-30
 * @version: 0.0.1
 */
import React, { Component } from "react";
import { ActionsWrapper, BackImage, Container, Title, TitleWrapper } from "./Header.style.";
import backImg from "../../../assets/images/back@2x.png";

var PageHeader = /*#__PURE__*/function (_Component) {
  _inherits(PageHeader, _Component);

  function PageHeader() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, PageHeader);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(PageHeader)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _this.handleTabChange = function (key) {
      var onTabsChange = _this.props.onTabsChange;

      if (onTabsChange) {
        onTabsChange(key);
      }
    };

    return _this;
  }

  _createClass(PageHeader, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          title = _this$props.title,
          children = _this$props.children,
          tabsConfig = _this$props.tabsConfig,
          hideBackBtn = _this$props.hideBackBtn,
          onBack = _this$props.onBack,
          className = _this$props.className,
          style = _this$props.style;
      var _tabsConfig$tabs = tabsConfig.tabs,
          tabs = _tabsConfig$tabs === void 0 ? [] : _tabsConfig$tabs;
      return React.createElement(Container, {
        className: "page-head ".concat(className),
        style: style
      }, React.createElement(TitleWrapper, {
        className: "title-wrapper"
      }, !hideBackBtn && React.createElement(BackImage, {
        src: backImg,
        onClick: onBack
      }), title && React.createElement(Title, {
        key: "page-head-title",
        className: "page-head-title"
      }, title), React.createElement(ActionsWrapper, {
        key: "page-head-operator",
        className: "page-head-operator"
      }, children)), tabs.length > 0 ? React.createElement("div", {
        className: "tabs-wrapper"
      }) : null);
    }
  }]);

  return PageHeader;
}(Component);

PageHeader.defaultProps = {
  className: "",
  style: {},
  title: "",
  onBack: function onBack() {},
  hideBackBtn: false,
  tabsConfig: {}
};
export default PageHeader;
